<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('应聘人员信息列表')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>招聘名称：</label>
                                <select id="recruitId" name="recruitId" class="form-control">
                                    <option value="0">所有</option>
                                    <option th:each="info : ${infos}" th:text="${info['recruitName']}" th:value="${info['recruitId']}" th:field="*{recruitInfo.recruitId}"></option>
                                </select>
                            </li>
                            <li>
                                <label>岗位名称：</label>
                                <input type="text" name="postName"/>
                            </li>
                            <li>
                                <label>姓名：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>性别：</label>
                                <select name="sex" class="form-control" th:with="type=${@dict.getType('sys_user_sex')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>学历：</label>
                                <select name="educateName" class="form-control" th:with="type=${@dict.getType('basic_educate_name')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>学位：</label>
                                <select name="degreeName" class="form-control" th:with="type=${@dict.getType('basic_educate_degree')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>毕业时间：</label>
                                <input type="text" class="time-input" id="finishTime" data-type="month" name="finishTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="recruit:user:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="recruit:user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="recruit:user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="importExcel()" shiro:hasPermission="recruit:user:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="recruit:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('recruit:user:edit')}]];
        var removeFlag = [[${@permission.hasPermi('recruit:user:remove')}]];
        var sexDatas = [[${@dict.getType('sys_user_sex')}]];
        var educateNameDatas = [[${@dict.getType('basic_educate_name')}]];
        var educateDegreeDatas = [[${@dict.getType('basic_educate_degree')}]];
        var prefix = ctx + "recruit/user";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                importTemplateUrl: prefix + "/importTemplate",
                modalName: "应聘人员信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'userId',
                    title: '人员id',
                    visible: false
                },
                {
                    field: 'recruitName',
                    title: '招聘名称'
                },
                {
                    field: 'postName',
                    title: '岗位名称'
                },
                {
                    field: 'postCode',
                    title: '岗位代码'
                },
                {
                    field: 'postLevel',
                    title: '岗位层次'
                },
                {
                    field: 'name',
                    title: '姓名'
                },
                {
                    field: 'sex',
                    title: '性别',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(sexDatas, value);
                    }
                },
                {
                    field: 'idCard',
                    title: '身份证号'
                },
                {
                    field: 'phonenumber',
                    title: '手机号码'
                },
                {
                    field: 'educateName',
                    title: '学历',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(educateNameDatas, value);
                    }
                },
                {
                    field: 'degreeName',
                    title: '学位',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(educateDegreeDatas, value);
                    }
                },
                {
                    field: 'schoolName',
                    title: '毕业学校'
                },
                {
                    field: 'majorName',
                    title: '所学专业'
                },
                {
                    field: 'finishTime',
                    title: '毕业时间',
                    sortable: true
                },
                {
                    field: 'birthday',
                    title: '出生日期',
                    sortable: true
                },
                {
                    field: 'fileUrl',
                    title: '报名材料',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.userId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function add(){
            var recruitId = $("#recruitId").val();
            $.operate.add(recruitId);
        }

        function importExcel() {
            var recruitId = $("#recruitId").val();
            if(recruitId == 0){
                $.modal.msgError("请选择要导入的应聘人员信息");
                return;
            }
            layer.open({
                type: 1,
                area: ['400px', '230px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: '导入应聘人员数据',
                content: $('#importTpl').html(),
                btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
                // 弹层外区域关闭
                shadeClose: true,
                btn1: function(index, layero){
                    var file = layero.find('#file').val();
                    if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
                        $.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
                        return false;
                    }
                    var index = layer.load(2, {shade: false});
                    $.modal.disable();
                    var formData = new FormData(layero.find('form')[0]);
                    formData.set("recruitId", recruitId);
                    $.ajax({
                        url: table.options.importUrl,
                        data: formData,
                        cache: false,
                        contentType: false,
                        processData: false,
                        type: 'POST',
                        success: function (result) {
                            if (result.code == web_status.SUCCESS) {
                                $.modal.closeAll();
                                $.modal.alertSuccess(result.msg);
                                $.table.refresh();
                            } else if (result.code == web_status.WARNING) {
                                layer.close(index);
                                $.modal.enable();
                                $.modal.alertWarning(result.msg)
                            } else {
                                layer.close(index);
                                $.modal.enable();
                                $.modal.alertError(result.msg);
                            }
                        }
                    });
                }
            });
        }
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果招聘计划已经存在，更新这条数据。"> 是否更新已经存在的招聘计划
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>